package com.mitaotao._1_语法._3_分支._1_数值交换;

public class _03_数值交换_异或运算 {
    public static void main(String[] args) {
        int a = 2;
        int b = 3;
        System.out.println("数值交换之前a为："+a);
        System.out.println("数值交换之前b为："+b);

        a = a ^ b;//a = 2 ^ 3;a:2,b:3
        b = a ^ b;//b = 1 ^ 3;a:1,b:3
        a = a ^ b;//a = 1 ^ 1;a:1,b:2
        System.out.println("数值交换之后a为："+a);//a:3
        System.out.println("数值交换之后b为："+b);//b:2
    }
}
